package main

import (
	"fmt"
	"net"
	"sync"
)

func progress(conn net.Conn) {
	defer conn.Close()
	wg.Add(1)
	for {
		data := make([]byte, 128)
		_, err3 := conn.Read(data)
		if err3 != nil {
			fmt.Println(err3)
			break
		}
		fmt.Println("GetMsg: ", string(data))
	}
	wg.Done()
}

var wg = sync.WaitGroup{}

func main() {
	listener, err := net.Listen("tcp", "127.0.0.1:20000")
	if err != nil {
		fmt.Println(err)
		return
	}
	for {
		conn, err1 := listener.Accept()
		if err1 != nil {
			fmt.Println(err1)
			return
		} else {
			fmt.Println("connect success")
		}
		go progress(conn)
		//wg.Wait()
	}
}
